import {
  getUserCenterRiskList,
} from '../../services/channel/api';


export default {
  namespace: 'creditCheck',

  state: {

    loading: true,

    creditCheckData: {
      list: [],
      pagination:{}
    },

  },

  effects: {

    *fetchGetUserCenterRiskList({payload, callback}, { call, put }) {
      const response = yield call(getUserCenterRiskList, payload);
      if (response && response.code == 200) {
        yield put({
          type: 'save',
          payload: {
            creditCheckData: {
              list: response.data.records,
              pagination: {
                current: response.data.current,
                total: response.data.total,
                size: response.data.size,
              }
            }
          },
        });
        if (callback) callback();
      }
    },
    
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },

};
